package com.github.cyf.interceptor.encrypt.impl;

import com.github.cyf.interceptor.encrypt.IEncryptResultFieldStrategy;
import org.springframework.stereotype.Component;
import org.springframework.util.DigestUtils;

/**
 * @author chenyifan
 * @create 2024-04-14 17:51
 */
@Component
public class MD5EncryptStrategy implements IEncryptResultFieldStrategy {

    @Override
    public String encrypt(String source) {
        if (source == null) {
            return null;
        }
        byte[] bytes = DigestUtils.md5Digest(source.getBytes());
        return String.valueOf(bytes);
    }
}
